package com.hongxun.modules.bss.service.impl;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.hongxun.modules.bss.dao.DOtherCostDao;
import com.hongxun.modules.bss.entity.DOtherCostEntity;
import com.hongxun.modules.bss.service.DOtherCostService;



@Service("dOtherCostService")
public class DOtherCostServiceImpl implements DOtherCostService {
	@Autowired
	private DOtherCostDao dOtherCostDao;

	@Override
	public DOtherCostEntity queryObject(String guid){
		return dOtherCostDao.queryObject(guid);
	}
	
	@Override
	public List<DOtherCostEntity> queryList(Map<String, Object> map){
		return dOtherCostDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return dOtherCostDao.queryTotal(map);
	}
	
	@Override
	public void save(DOtherCostEntity dOtherCost){
        if(dOtherCost.getGuid()==null||dOtherCost.getGuid().equals("")) {

		    dOtherCost.setGuid(UUID.randomUUID().toString());
        }
		dOtherCostDao.save(dOtherCost);
	}
	
	@Override
	public void update(DOtherCostEntity dOtherCost){
		dOtherCostDao.update(dOtherCost);
	}
	
	@Override
	public void delete(String guid){
		dOtherCostDao.delete(guid);
	}
	
	@Override
	public void deleteBatch(String[] guids){
		dOtherCostDao.deleteBatch(guids);
	}

	@Override
	public void insertOrReplaceOrDelete(List<DOtherCostEntity> entities) {
		for (DOtherCostEntity d : entities) {
			if (d.getCCDatastate().equals("删除")) {
				dOtherCostDao.delete(d.getGuid());
			} else {
				DOtherCostEntity dOtherCostEntity = dOtherCostDao.queryObject(d.getGuid());
				if (dOtherCostEntity == null) {
					dOtherCostDao.save(d);
				} else {
					dOtherCostDao.update(d);
				}
			}
		}
	}
}
